//
//  ZYCUserLoginModel.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/3.
//

#import "ZYCUserLoginModel.h"

@interface ZYCUserLoginModel ()<NSCoding>

@end
@implementation ZYCUserLoginModel


+(NSDictionary *) modelCustomPropertyMapper{
    return @{@"t_id" : @"id"};
}


#pragma mark - NSCoding delegate
//归档
-(void) encodeWithCoder:(NSCoder *)aCoder{
    [self yy_modelEncodeWithCoder:aCoder];
}

//解档
-(id) initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    return [self yy_modelInitWithCoder:aDecoder];
}


+ (ZYCUserLoginModel *)userLogin{
    NSData * data = [[NSUserDefaults standardUserDefaults] objectForKey:NSStringFromClass([ZYCUserLoginModel class])];
    if (data) {
        return [NSKeyedUnarchiver unarchiveObjectWithData:data];
    }else{
        return nil;
    }
}

+ (BOOL)deleteUserLogin{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:NSStringFromClass([ZYCUserLoginModel class])];
    return [[NSUserDefaults standardUserDefaults] synchronize];
}

- (BOOL)saveUserLogin{
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self];
    [[NSUserDefaults standardUserDefaults] setObject:data forKey:NSStringFromClass([ZYCUserLoginModel class])];
    return [[NSUserDefaults standardUserDefaults] synchronize];
}

@end
